package com.lijiajia.cloud.authserver.pojo.mongodb;

import lombok.Data;
import lombok.experimental.Accessors;
import org.bson.types.ObjectId;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.Id;
import org.springframework.data.annotation.LastModifiedDate;
import org.springframework.data.mongodb.core.mapping.Document;

import java.time.LocalDateTime;

/**
 * 持久登陆
 *
 * @author lijiajia
 * @since 2019-04-30
 */
@Data
@Accessors(chain = true)
@Document(collection = "persistent_login")
public class PersistentLogin {

    @Id
    private ObjectId mongodbId;

    /**
     * cookie值
     */
    private String series;
    /**
     * 用户名
     */
    private String username;
    /**
     * token值
     */
    private String token;
    /**
     * 最后使用时间
     */
    private LocalDateTime lastUsed;

    /**
     * 创建时间
     */
    @CreatedDate
    private LocalDateTime createdAt;
    public static final String CREATED_AT = "created_at";
    /**
     * 最后修改时间
     */
    @LastModifiedDate
    private LocalDateTime lastModifiedAt;
    public static final String LAST_MODIFIED_AT = "last_modified_at";

    public static final String SERIES = "series";
    public static final String USERNAME = "username";
    public static final String TOKEN = "token";
    public static final String LAST_USED = "last_used";
}
